package com.zhongxi.guoyuan.view.beautifulStore;

import android.os.Bundle;
import android.util.SparseArray;
import com.zhongxi.guoyuan.base.BaseFragment;
import com.zhongxi.guoyuan.fragment.beautifulStore.BestPriceBeautifulFragment;
import com.zhongxi.guoyuan.fragment.beautifulStore.GoodProjectBeautifulFragment;
import com.zhongxi.guoyuan.fragment.beautifulStore.NewBeautifulFragment;

/**
 * Created by Administrator on 2017/10/17.
 */

public class BeautifulFragmentFactory {
    static SparseArray<BaseFragment> fragmentMap = new SparseArray<>();

    public static BaseFragment create(int position, String trim) {
        BaseFragment fragment = fragmentMap.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new NewBeautifulFragment();
                    break;
                case 1:
                    fragment = new BestPriceBeautifulFragment();
                    break;
                case 2:
                    fragment = new GoodProjectBeautifulFragment();
                    break;
            }
            if (fragment != null) {
                fragmentMap.put(position, fragment);
            }
        }
        Bundle args=new Bundle();
        args.putString("trim",trim);
        fragment.setArguments(args);
        return fragment;
    }
}
